/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityprojet;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author T.Ron
 */
@Entity
@Table(name = "BUDGETPB")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Budgetpb.findAll", query = "SELECT b FROM Budgetpb b"),
    @NamedQuery(name = "Budgetpb.findByIdPb", query = "SELECT b FROM Budgetpb b WHERE b.budgetpbPK.idPb = :idPb"),
    @NamedQuery(name = "Budgetpb.findByNumexo", query = "SELECT b FROM Budgetpb b WHERE b.budgetpbPK.numexo = :numexo"),
    @NamedQuery(name = "Budgetpb.findByMois", query = "SELECT b FROM Budgetpb b WHERE b.budgetpbPK.mois = :mois"),
    @NamedQuery(name = "Budgetpb.findByMontantdotforte", query = "SELECT b FROM Budgetpb b WHERE b.montantdotforte = :montantdotforte"),
    @NamedQuery(name = "Budgetpb.findByMontantdotfaible", query = "SELECT b FROM Budgetpb b WHERE b.montantdotfaible = :montantdotfaible")})
public class Budgetpb implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BudgetpbPK budgetpbPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "MONTANTDOTFORTE")
    private BigDecimal montantdotforte;
    @Column(name = "MONTANTDOTFAIBLE")
    private BigDecimal montantdotfaible;
    @JoinColumn(name = "ID_PB", referencedColumnName = "ID_PB", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Postebudgetaire postebudgetaire;
    @JoinColumns({
        @JoinColumn(name = "NUMEXO", referencedColumnName = "NUMEXO", insertable = false, updatable = false),
        @JoinColumn(name = "MOIS", referencedColumnName = "MOIS", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Periode periode;

    public Budgetpb() {
    }

    public Budgetpb(BudgetpbPK budgetpbPK) {
        this.budgetpbPK = budgetpbPK;
    }

    public Budgetpb(int idPb, int numexo, int mois) {
        this.budgetpbPK = new BudgetpbPK(idPb, numexo, mois);
    }

    public BudgetpbPK getBudgetpbPK() {
        return budgetpbPK;
    }

    public void setBudgetpbPK(BudgetpbPK budgetpbPK) {
        this.budgetpbPK = budgetpbPK;
    }

    public BigDecimal getMontantdotforte() {
        return montantdotforte;
    }

    public void setMontantdotforte(BigDecimal montantdotforte) {
        this.montantdotforte = montantdotforte;
    }

    public BigDecimal getMontantdotfaible() {
        return montantdotfaible;
    }

    public void setMontantdotfaible(BigDecimal montantdotfaible) {
        this.montantdotfaible = montantdotfaible;
    }

    public Postebudgetaire getPostebudgetaire() {
        return postebudgetaire;
    }

    public void setPostebudgetaire(Postebudgetaire postebudgetaire) {
        this.postebudgetaire = postebudgetaire;
    }

    public Periode getPeriode() {
        return periode;
    }

    public void setPeriode(Periode periode) {
        this.periode = periode;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (budgetpbPK != null ? budgetpbPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Budgetpb)) {
            return false;
        }
        Budgetpb other = (Budgetpb) object;
        if ((this.budgetpbPK == null && other.budgetpbPK != null) || (this.budgetpbPK != null && !this.budgetpbPK.equals(other.budgetpbPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityprojet.Budgetpb[ budgetpbPK=" + budgetpbPK + " ]";
    }
    
}
